package com.accp.electronicdocumentmanagementsystem.biz;

import com.accp.electronicdocumentmanagementsystem.dao.EntrMapper;
import com.accp.electronicdocumentmanagementsystem.pojo.Entr;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Entrbiz {

    @Autowired(required = false)
    private EntrMapper entrMapper;

    public boolean insertEntr(Entr entr){
        return entrMapper.insert(entr) > 0;
    }
    public boolean deleteEntr(Long id){
        return entrMapper.deleteByPrimaryKey(id) > 0;
    }
    public boolean updateEntr(Entr entr){
        return entrMapper.updateByPrimaryKey(entr) > 0;
    }

    public Entr selEntr(Long id){
        return entrMapper.selectByPrimaryKey(id);
    }

    public PageInfo selEntr(String name, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        if (name.equals("全部")) {
            return new PageInfo(entrMapper.selectAll(null));
        }
        return new PageInfo(entrMapper.selectAll(name));
    }
}
